var e, t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), a = require("../../../@babel/runtime/helpers/asyncToGenerator"), n = require("../../../utils/DPagination").default, r = require("../common"), o = r.getProjectNameLang, i = r.getLocation, s = getApp(), c = new n("projects"), u = s.getNetAddresss("plugin.store-projects.frontend.project.get-list"), l = null;

Page({
    data: {
        categoryId: null,
        projects: {},
        projectCount: 0,
        projectNameLang: o()
    },
    onLoad: (e = a(t.default.mark(function e(a) {
        return t.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                return wx.setNavigationBarTitle({
                    title: o() + "列表"
                }), e.next = 3, i();

              case 3:
                if (l = e.sent, a.category_id) {
                    e.next = 7;
                    break;
                }
                return wx.showToast({
                    title: "分类不存在",
                    icon: "none"
                }), e.abrupt("return");

              case 7:
                c.bind(this), c.clean(), this.setData({
                    categoryId: a.category_id
                }), this.getProjects();

              case 11:
              case "end":
                return e.stop();
            }
        }, e, this);
    })), function(t) {
        return e.apply(this, arguments);
    }),
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        c.clean(), this.getProjects();
    },
    onReachBottom: function() {
        this.getProjects();
    },
    onShareAppMessage: function() {
        return {
            path: "/packageH/project_verification/CategoryProjectList/CategoryProjectList?category_id=" + this.data.categoryId
        };
    },
    onShareTimeline: function() {
        return {
            query: "project_id=" + this.data.categoryId
        };
    },
    getProjects: function() {
        var e = this;
        if (!c.loading && !c.finished) {
            c.loading = !0;
            var t = s.qqMapTransBMap(parseFloat(l.point.lng), parseFloat(l.point.lat));
            s._getNetWork({
                url: u,
                data: {
                    page: c.loadPage,
                    category_id: this.data.categoryId,
                    lng: t.lng,
                    lat: t.lat
                },
                success: function(t) {
                    var a = t.data.data;
                    (a.current_page == a.last_page || a.data.length < a.per_page) && (c.finished = !0), 
                    c.push(a.data), c.loading = !1, wx.stopPullDownRefresh(), e.setData({
                        projectCount: c.length
                    });
                },
                fail: function() {
                    c.loading = !1, wx.stopPullDownRefresh();
                }
            });
        }
    }
});